Adaptive cache promotions in a two level caching system

ABSTRACT

Provided are a computer program product, system, and method for managing data in a first cache and a second cache. A reference count is maintained in the second cache for the page when the page is stored in the second cache. It is determined that the page is to be promoted from the second cache to the first cache. In response to determining that the reference count is greater than zero, the page is added to a Least Recently Used (LRU) end of an LRU list in the first cache. In response to determining that the reference count is less than or equal to zero, the page is added to a Most Recently Used (LRU) end of the LRU list in the first cache.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a computer program product, system, andmethod for adaptive cache promotions in a two level caching system.

2. Description of the Related Art

A cache management system buffers pages in a storage device recentlyaccessed as a result of read and write operations in a faster accessstorage device, such as memory, than the storage device storing therequested pages. Subsequent read requests to pages in the faster accesscache memory are returned at a faster rate than returning the requestedpages from the slower access storage, thus reducing read latency. Thecache management system may also return complete to a write request whenthe modified page directed to the storage device is written to the cachememory and before the modified page is written out to the storagedevice, such as a hard disk drive. The write latency to the storagedevice is typically significantly longer than the latency to write to acache memory. Thus, using cache also reduces write latency.

A cache management system may maintain a linked list having one entryfor each page stored in the cache, which may comprise write databuffered in cache before writing to the storage device or read data. Inthe commonly used Least Recently Used (LRU) cache technique, if a pagein the cache is accessed, i.e., a cache “hit”, then the entry in the LRUlist for the accessed page is moved to a Most Recently Used (MRU) end ofthe list. If the requested page is not in the cache, i.e., a cache miss,then the page in the cache whose entry is at the LRU end of the list maybe removed (or destaged back to storage) and an entry for the page datastaged into cache from the storage is added to the MRU end of the LRUlist. With this LRU cache technique, pages that are more frequentlyaccessed are likely to remain in cache, while data less frequentlyaccessed will more likely be removed from the LRU end of the list tomake room in cache for newly accessed pages.

The LRU cache technique seeks to optimize for temporal locality so as todestage pages that are least likely to be rewritten soon in order tominimize the number of destage operations, i.e., if a write that is notdestaged is overwritten than the destaging of the overwritten write isavoided, thus saving the time and effort of writing the data from cacheto disk. On the other hand there is also a desire to destage in a mannerthat exploits spatial locality, which means that data is written tostorage locations that are closest to each other to minimize thedistance the storage device write mechanism and storage media needs tobe moved to reach the next storage location to write.

One technique for exploiting both temporal and spatial locality is theWise Ordering for Writes (WOW) algorithm. The WOW algorithm employs acircular linked list or clock where the circular linked list has oneentry for each write request buffered in cache. The entries are orderedin the linked list according to the storage location to which theassociated write request is directed to exploit the benefits of spatiallocality. Further, each entry includes a bit indicating whether thewrite data for the storage location in the cache has been recentlyupdated. The bit for an entry is set when the write data for the entryis updated. A pointer points to a current entry in the circular linkedlist. A task using the WOW algorithm accesses an entry addressed by thepointer. If the bit for the entry indicates that the data for the entryin cache has been recently updated, then the bit is set to indicate thatthe write data has not been recently updated and the pointer incrementedto point to the next entry so that the entry having write data to astorage location next closest in spatial proximity to the previouslywritten storage location is considered. The entry is selected to writethat is closest in spatial proximity to the last written storagelocation and whose bit indicates that the write data for the entry hasnot recently been updated.

Thus, with the WOW algorithm, spatial locality is exploited because anext entry to write is selected for consideration that is closest inspatial proximity to the last destaged write request. Further, temporallocality is exploited because an entry that has recently been writtenwill be skipped until the pointer circles back to that skipped entry toconsider.

Disk drives may implement the WOW algorithm and other algorithms thattake both the linear and the angular position of the write pages intoaccount and optimize for both with respect to a current write headposition to determine the minimal total service time. This process isreferred to as “command re-ordering based on seek and rotationaloptimization”. The disk drive logic boards will analyze write requestsand determine which to do first based on both how much time will berequired to seek to the various cylinders and angular position of thepage to write, and how much time will elapse waiting for the data torotate under the heads.

There is a need in the art for improved techniques for using a two levelcaching system.

SUMMARY

Provided are a computer program product, system, and method for managingdata in a first cache and a second cache. A reference count ismaintained in the second cache for the page when the page is stored inthe second cache. It is determined that the page is to be promoted fromthe second cache to the first cache. In response to determining that thereference count is greater than zero, the page is added to a LeastRecently Used (LRU) end of an LRU list in the first cache. In responseto determining that the reference count is less than or equal to zero,the page is added to a Most Recently Used (LRU) end of the LRU list inthe first cache.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 illustrates an embodiment of a computing environment.

FIG. 2 illustrates an embodiment of first cache management information.

FIG. 3 illustrates an embodiment of second cache management information.

FIG. 4 illustrates an embodiment of a first cache control block.

FIG. 5 illustrates an embodiment of a second cache control block.

FIG. 6 illustrates an embodiment of a spatial index entry.

FIG. 7 illustrates an embodiment of operations to demote unmodifiedpages from the first cache.

FIG. 8 illustrates an embodiment of operations to destage modified pagesfrom the first cache.

FIG. 9 illustrates an embodiment of operations to add a page to thefirst cache.

FIG. 10 illustrates an embodiment of operations to promote a page to thesecond cache.

FIG. 11 illustrates an embodiment of operations to free space in thesecond cache.

FIG. 12 illustrates an embodiment of operations to destage modifiedpages from the second cache.

FIG. 13 illustrates an embodiment of operations to process a request forpages to return to a read request.

FIG. 14 illustrates an embodiment of a two level caching system andstorage.

FIG. 15 illustrates an embodiment of operations to add a page to a firstcache from a second cache.

DETAILED DESCRIPTION

FIG. 1 illustrates an embodiment of a computing environment. A pluralityof hosts 2 a, 2 b . . . 2 n may submit Input/Output (I/O) requests to astorage controller 4 over a network 6 to access data at volumes 8 (e.g.,Logical Unit Numbers, Logical Devices, Logical Subsystems, etc.) in astorage 10, which is coupled to the storage controller 4. The storagecontroller 4 includes a processor complex 12, including one or moreprocessors with single or multiple cores, a first cache 14, a firstcache backup device 16, to backup pages in the cache 14, and a secondcache 18. The first 14 and second 18 caches cache data transferredbetween the hosts 2 a, 2 b . . . 2 n and the storage 10. The first cachebackup device 16 may provide non-volatile storage of pages in the firstcache 14. In a further embodiment, the first cache backup device 16 maybe located in a cluster or hardware on a different power boundary thanthat of the first cache 14.

The storage controller 4 has a memory 20 that includes a storage manager22 for managing the transfer of pages transferred between the hosts 2 a,2 b . . . 2 n and the storage 10 and a cache manager 24 that managesdata transferred between the hosts 2 a, 2 b . . . 2 n and the storage 10in the first cache 14, first cache backup device 16, and the secondcache 18. A page may comprise any unit of data configured in the storage10, such as a page, Logical Block Address (LBA), etc., which is part ofa larger grouping of pages, such as a volume, logical device, etc. Thecache manager 24 maintains first cache management information 26 andsecond cache management information 28 to manage read (unmodified) andwrite (modified) pages in the first cache 14 and the second cache 18. Afirst cache backup device index 30 provides an index of page identifiersto a location in the first cache backup device 16.

The storage manager 22 and cache manager 24 are shown in FIG. 1 asprogram code loaded into the memory 20 and executed by the processorcomplex 12. Alternatively, some or all of the functions may beimplemented in hardware devices in the storage controller 4, such as inApplication Specific Integrated Circuits (ASICs).

The second cache 18 may store pages in a log structured array (LSA) 32,where pages are written in a sequential order as received, thusproviding a temporal ordering of the pages written to the second cache18. In a LSA, later versions of pages already present in the LSA arewritten at the end of the LSA 32. In alternative embodiments, the secondcache 18 may store data in formats other than in an LSA.

In certain embodiments, the first cache 14 may comprise a Random AccessMemory (RAM), such as a Dynamic Random Access Memory (DRAM), the secondcache 18 may comprise a flash memory, such as a solid state device, andthe storage 10 is comprised of one or more sequential access storagedevices, such as hard disk drives and magnetic tape. The storage 10 maycomprise a single sequential access storage device or may comprise anarray of storage devices, such as a Just a Bunch of Disks (JBOD), DirectAccess Storage Device (DASD), Redundant Array of Independent Disks(RAID) array, virtualization device, etc. The storage 10 is coupled toat least one of the first cache 14 and the second cache 18. In certainembodiments, the first cache 14 is a faster access device than thesecond cache 18, and the second cache 18 is a faster access device thanthe storage 10. Further, the first cache 14 may have a greater cost perunit of storage than the second cache 18 and the second cache 18 mayhave a greater cost per unit of storage than storage devices in thestorage 10. Moreover, in certain embodiments, the second cache 18 may bemuch larger than the first cache 14.

The first cache 14 may be part of the memory 20 or implemented in aseparate memory device, such as a DRAM. In certain embodiments, thefirst cache backup device 16 may comprise a non-volatile backup storage(NVS), such as a non-volatile memory, e.g., battery backed-up RandomAccess Memory (RAM), static RAM (SRAM), etc.

The network 6 may comprise a Storage Area Network (SAN), a Local AreaNetwork (LAN), a Wide Area Network (WAN), the Internet, and Intranet,etc.

Although certain embodiments herein reference a cache index granularityof pages, other embodiments apply to data of different cache indexgranularity, such as tracks or extents.

FIG. 2 illustrates an embodiment of the first cache managementinformation 26 including a page index 50 providing an index of pages inthe first cache 14 to control blocks in a control block directory 52; anunmodified sequential LRU list 54 providing a temporal ordering ofunmodified sequential pages in the first cache 14; a modified LRU list56 providing a temporal ordering of modified sequential andnon-sequential pages in the first cache 14; an unmodified non-sequentialLRU list 58 providing a temporal ordering of unmodified non-sequentialpages in the first cache 14; reference counters 60; and accelerated LRU62.

FIG. 3 illustrates an embodiment of the second cache managementinformation 28 including a page index 70 providing an index of pages inthe second cache 18 to control blocks in a control block directory 72;an unmodified list 74 providing a temporal ordering of unmodified pagesin the second cache 18; a spatial index 76 providing a spatial orderingof the modified pages in the second cache 18 based on the physicallocations in the storage 10 at which the modified pages are stored; andreference counters 78.

All the LRU lists 54, 56, 58, and 74 may include the page IDs of pagesin the first cache 14 and the second cache 18 ordered according to whenthe identified page was last accessed. The LRU lists 54, 56, 58, and 74have a most recently used (MRU) end indicating a most recently accessedpage and a LRU end indicating a least recently used or accessed page.The page IDs of pages added to the caches 14 and 18 are added to eitherthe MRU end or the LRU end (depending on the heat of the page) of theLRU list and pages demoted from the caches 14 and 18 are accessed fromthe LRU end. The page indexes 50 and 70 and spatial index 76 maycomprise a scatter index table (SIT). Alternative type data structuresmay be used to provide the temporal ordering of pages in the caches 14and 18 and spatial ordering of pages in the second cache 18.

Non-sequential pages may comprise Online Line Transaction Processing(OLTP) pages, which often comprise small block writes that are not fullyrandom and have some locality of reference, i.e., have a probability ofbeing repeatedly accessed.

FIG. 4 illustrates an embodiment of a first cache control block 100entry in the control block directory 52, including a control blockidentifier (ID) 102, a first cache location 104 of the physical locationof the page in the first cache 14, information 106 indicating whetherthe page is modified or unmodified, and information 108 indicatingwhether the page is a sequential or non-sequential access.

FIG. 5 illustrates an embodiment of a second cache control block 120entry in the second cache control block directory 72, including acontrol block identifier (ID) 122, an LSA location 124 where the page islocated in the LSA 32, and information 126 indicating whether the pageis modified or unmodified.

FIG. 6 illustrates an embodiment of a spatial index entry 140 includinga page identifier 142 of a page in the second cache 18 and the physicallocation 144 of where the page is stored in the storage 10, such as acylinder, platter, block address, and storage device identifier.

FIG. 7 illustrates an embodiment of operations performed by the cachemanager 24 to demote unmodified pages from the first cache 14. Thedemote operation may be initiated upon determining to free space in thefirst cache 14. Upon initiating (at block 200) an operation to determinewhether to remove pages from the first cache 14 to free space in thefirst cache 14, the cache manager 24 determines (at block 202) whetherto demote non-sequential or sequential unmodified pages based onexpected hits to different types of unmodified pages. If (at block 204)the determination is to demote unmodified sequential pages, then thecache manager 24 uses (at block 206) the unmodified sequential LRU list54 to determine unmodified sequential pages to demote, from the LRU endof the list, which are not promoted to the second cache 18. If (at block204) the determination is made to demote unmodified non-sequentialpages, then the cache manager uses the unmodified non-sequential LRUlist 58 to determine (at block 208) unmodified non-sequential pages todemote. The unmodified non-sequential pages are promoted (at block 210)to the second cache 18.

FIG. 8 illustrates an embodiment of operations performed by the cachemanager 24 to destage modified pages from the first cache 14. The cachemanager 24 may regularly destage pages as part of scheduled operationsand increase the rate of destages if space is needed in the first cachebackup device 16. Upon initiating (at block 250) the operation todestage modified pages, the cache manager 24 processes (at bock 252) themodified LRU list 56 to determine modified pages to destage, from theLRU end of the LRU list 56. If (at block 254) the determined modifiedpages are sequential, then the cache manager 24 writes (at block 256)the determined modified sequential pages to the storage 10, bypassingthe second cache 18. If (at block 254) the modified pages arenon-sequential, then the cache manager 24 promotes (at block 258) thedetermined modified non-sequential pages to the second cache 18 anddiscards (at block 260) the copy of the determined modified pages fromthe first cache backup device 16.

With the operations of FIGS. 7 and 8, non-sequential pages are demotedbut not promoted to the second cache 18. Sequential modified (writes)are written directly to the storage 10, bypassing the second cache.Sequential unmodified pages (reads) are discarded and not copiedelsewhere, and unmodified non-sequential pages demoted from the firstcache 14 are promoted to the second cache 18.

FIG. 9 illustrates an embodiment of operations performed by the cachemanager 24 to add, i.e., promote, a page to the first cache 14, whichpage may comprise a write or modified page from a host 2 a, 2 b . . . 2n or read requested data not found in either cache 14 or 18 andretrieved from the storage 10. Upon receiving (at block 300) the page toadd to the first cache 14, the cache manager 24 creates (at block 301) acontrol block 100 (FIG. 4) for the page to add indicating the 104location in the first cache 14 and whether the page ismodified/unmodified 106 and sequential/non-sequential 108. This controlblock 100 is added to the control block directory 52 of the first cache14. The cache manager 24 adds (at block 302) an entry to the first cachepage index 50 having the page ID of page to add and an index to thecreated cache control block 100 in the control block directory 52. Anentry is added (at block 304) to the MRU end of the LRU list 54, 56 or58 of the page type of the page to add. If (at block 306) the page toadd is a modified non-sequential page, then the page to add is alsocopied (at block 308) to the first cache backup device 16 and an entryis added to the first cache backup device index 30 for the added page.If (at block 306) the page to add is unmodified sequential, controlends.

FIG. 10 illustrates an embodiment of operations performed by the cachemanager 24 to promote non-sequential pages to the second cache 18 thatis being demoted from the first cache 14. Upon initiating (at block 350)the operation to promote a page to the second cache 18, the cachemanager 24 adds (at block 352) the page being promoted to the LSA 32 inthe second cache 18 and creates (at block 354) a control block 120 (FIG.5) for the page to add indicating the page location 124 in the LSA 32and whether the page is modified/unmodified 126. An entry is added (atblock 356) to the second cache page index 70 having the page ID of thepromoted page and an index to the created cache control block 120 in thecontrol block directory 72 for the second cache 18. If (from the nobranch of block 358) the page being promoted is unmodified data, thenthe cache manager 24 indicates (at block 360) the promoted page at theMRU end of the unmodified LRU list 74, such as by adding the page ID tothe MRU end. If (at block 358) the promoted page is modified data, thenthe cache manager 24 determines (at block 362) a physical location ofthe where to write the modified promoted page on the storage 10 and adds(at block 364) an entry to the spatial index 76 indicating the page ID142 of the promoted page and the determined physical location 144 of thepromoted page on the storage 10.

FIG. 11 illustrates an embodiment of operations performed by the cachemanager 24 to free space in the second cache 18 for new pages to add tothe second cache 18, i.e., pages being demoted from the first cache 14.Upon initiating this operation (at block 400) the cache manager 24determines (at block 402) unmodified pages in the second cache 18 fromthe LRU end of the unmodified LRU list 74 and invalidates (at block 404)the determined unmodified pages without destaging the invalidatedunmodified pages to the storage 10, and also removes the invalidatedunmodified pages from the unmodified LRU list 74.

FIG. 12 illustrates an embodiment of operations performed by the cachemanager 24 to destage modified pages in the second cache 12 to thestorage 10. Upon initiating (at block 420) the destage operation, thecache manager 24 uses (at block 422) the spatial index 76 to determinemodified pages in the second cache 18 to group that are at proximatephysical locations on the storage 10 based on their order in the spatialindex 76, such as a group of pages at consecutive entries 140 (FIG. 6)in the location ordered spatial index 76. The determined groupedmodified pages are destaged (at block 424) from the second cache 18 tothe storage 10.

The operations of FIG. 12 optimize write operations to the storage 10,which comprises a sequential access storage device, by having thestorage 10 write pages at physical locations at closest physicalproximity on the storage 10 writing surface, thus minimizing the amountof seeking and movement of the storage 10 write head to write the pagesin the second cache 18 to storage 10. The pages were promoted to thesecond cache 18 from the from the first cache 16 based on temporalfactors, such as their position in an LRU list 54, 56, 58, and not in anorder optimized for sequential writing to a sequential access storage10, such as a hard disk drive. Thus, the operations of FIG. 12 optimizethe temporally ordered modified pages based on their spatial location onthe storage 10 to optimize writing at the storage 10.

FIG. 13 illustrates an embodiment of operations performed by the cachemanager 24 to retrieve requested pages for a read request from thecaches 14 and 18 and storage 10. The storage manager 22 processing theread request may submit requests to the cache manager 24 for therequested pages. Upon receiving (at block 450) the request for thepages, the cache manager 24 uses (at block 454) the first cache pageindex 50 to determine whether all of the requested pages are in thefirst cache 14. If (at block 454) all requested pages are not in thefirst cache 14, then the cache manager 24 uses (at block 456) the secondcache page index 70 to determine any of the requested pages in thesecond cache 18 not in the first cache 14. If (at block 458) there areany requested pages not found in the first 14 and second 18 caches, thenthe cache manager 24 determines (at block 460) any of the requestedpages in the storage 10, from the second cache page index 70, not in thefirst 14 and the second 18 caches. The cache manager 24 then promotes(at block 462) any of the determined pages in the second cache 18 andthe storage 10 to the first cache 14. The cache manager 24 uses (atblock 464) the first cache page index 50 to retrieve the requested pagesfrom the first cache 14 to return to the read request. The entries forthe retrieved pages are moved (at block 466) to the MRU end of the LRUlist 54, 56, 58 including entries for the retrieved pages. With theoperations of FIG. 13, the cache manager 24 retrieves requested pagesfrom a highest level cache 14, then second cache 18 first before goingto the storage 10, because the caches 14 and 18 would have the mostrecent modified version of a requested page. The most recent version isfirst found in the first cache 14, then the second cache 18 if not inthe first cache 14 and then the storage 10 if not in either cache 14,18.

With the operations of FIG. 13, the cache manager 24 retrieves requestedpages from a highest level cache 14, then second cache 18 first beforegoing to the storage 10, because the caches 14 and 18 would have themost recent modified version of a requested page. The most recentversion is first found in the first cache 14, then the second cache 18if not in the first cache 14 and then the storage 10 if not in eithercache 14, 18.

Described embodiments provide techniques for allowing the use of asecond level cache between a primary or first level cache and a storageto increase the cache space when the fastest access first cache 14 hasthe most expensive space, cost per byte, and a second cache, lessexpensive than the first cache but faster than the storage, can be usedto increase the amount of cached data in the system. Increasing fasteraccess cached storage space improves access to the cached data whenrequested data is in the cache and can be returned from cache instead ofhaving to retrieve from the slower access, less expensive storage.Further, in described embodiments, pages are added to the second cachebased on a temporal ordering in the first cache, and then sorted in thesecond cache based on spatial physical location in the sequential accessstorage so that destaged pages are written in groups of pages atproximate or consecutive physical locations in the storage to optimizethe writing of the pages to the storage.

FIG. 14 illustrates an embodiment of a two level caching system 14, 18and storage 10. The two levels of cache are the first cache 14 and thesecond cache 18.

The cache manager 24 optimize the first cache 14 in a two level cachingsystem in which the first cache 14 and the second cache 18 are the twocaches forming the two level caching system. The cache manager 24predicts the utility of a page when the page is promoted from the secondcache 18 into the first cache 14. Based on the utility of the page, thecache manager 24 optimizes the first cache 14 by inserting the page inthe appropriate position in the appropriate LRU list 54, 56, 58.

The cache manager 24 improves utilization of the first cache 14 so thatpages that are promoted in the first cache 14 from the second cache 18are inserted in the LRU list 54, 56, 58 in the first cache 14 in afashion as to maximize hit ratio in the first cache 14.

In certain embodiments, a page is brought into the first cache 14 uponreference. Thus, a page is promoted to the first cache 14 on every hitof that page in the second cache 18. Nevertheless, if the heat of thepage is “cold” (i.e., not frequently accessed) in the second cache 18,the cache manager 24 does not want the cold page to occupy a first cache14 page frame for a long time; therefore, the cache manager 24 insertsthe cold page in the LRU list of the first cache 14, instead of the MRU,so that the cold page gets evicted soon. The cache manager 24 may inserta “hot” (i.e., frequently accessed) page at the MRU of the LRU list ofthe first cache 14.

The cache manager 24 identifies the heat of a page while the pageresides in the first and second caches 14, 18 by maintaining referencecounters 60, 78 in the first cache 14 and the second cache 18. Since anypage cached in the second cache 18 has previously been in the firstcache 14 and aged out of the first cache 14, the cache manager 24utilizes the following rule to identify whether a page currently cachedin the second cache 18 is still hot or has gone cold (i.e., should bepromoted to the MRU end of the LRU list of the first cache 14 or to theLRU end of the LRU list of the first cache 14, respectively): a pagefrom the second cache 18 is promoted to the MRU end of the LRU list ofthe first cache 14 if the page has seen more hits on the second cache 18than the hits the page had seen while the page had previously beencached in the first cache 14. In particular:

1. For both the first cache 14 and the second cache 18, referencecounters 60, 78 are maintained for each page. Let c_(R) and c_(F) bethose counters for the first cache 14 and the second cache 18,respectively.

2. While a page is cached in the first cache 14, c_(R) is incrementedupon every reference to the page.

3. When the page is demoted from the first cache 14 to the second cache18, if c_(F)<0, then c_(F) is initialized to kc_(R) (wherein k=1, 2, 3,. . . ). k is a constant that is used to adjust the heat of a page.

4. While the page is cached on the second cache, upon a reference to thepage, c_(F) is decremented, and:

-   -   If c_(F)>0, the page is promoted to the LRU end of the LRU list        of the first cache 14, so that the page is evicted soon;    -   Otherwise, the page is promoted to the MRU end of the LRU list        of the first cache 14.

In this way, pages that remain hot for a long time occupy frames in thefirst cache 14. Pages that start getting cold are pushed out to thesecond cache 18 and remain there for a much longer time, thereby gettinga second chance to be brought into the MRU position of the LRU list ofthe first cache 14 if those pages become hot in the near future. Incertain embodiments, c_(F) can be initialized to the maximum of kc_(R)and a constant K, if only pages that have seen at least K hits in thesecond cache 18 should be promoted to the MRU position of the LRU listof the first cache 14.

In certain embodiments, k is a static configuration parameter and is setby a system administrator. In certain alternative embodiments, k is adynamic configuration parameter that is automatically adjusted (e.g., bythe cache manager 24). In some of these alternative embodiments, k isdetermined as an average heat of the two caches 14, 18. Thus, krepresents an appropriate scaling factor for the two caches 14, 18.

In certain embodiments, the cold pages are promoted from the secondcache 18 into an accelerated LRU list 62 instead of being added to theLRU end of another LRU list of the first cache 14. When a page is to beevicted from the first cache 14, a page to be evicted is selected fromthe accelerated LRU list 62.

FIG. 15 illustrates an embodiment of operations performed by the cachemanager 24 to add, i.e., promote, a page to the first cache 14, whichpage may comprise a non-sequential page in the second cache 18 that issubject to a read request and as a result moved to the first cache 14from the second cache 18. Upon receiving (at block 500) the page to addto the first cache 14, the cache manager 24 creates (at block 502) acontrol block 100 (FIG. 4) for the page to add indicating the 104location in the first cache 14 and whether the page ismodified/unmodified 106 and sequential/non-sequential 108. This controlblock 100 is added to the control block directory 52 of the first cache14. The cache manager 24 adds (at block 504) an entry to the first cachepage index 50 having the page ID of page to add and an index to thecreated cache control block 100 in the control block directory 52.

In block 506, the cache manager 24 determines whether c_(f)>0 for thepage. If so, processing continues to block 510, otherwise, processingcontinues to block 512. An entry is added (at block 508) to the MRU endof the LRU list 54, 56 or 58 of the page type of the page to add. Anentry is added (at block 510) to the LRU end of the LRU list 54, 56 or58 of the page type of the page to add. If (at block 512) the page toadd is a modified non-sequential page, then the page to add is alsocopied (at block 514) to the first cache backup device 16 and an entryis added to the first cache backup device index 30 for the added page.If (at block 512) the page to add is unmodified sequential, controlends.

Thus, embodiments are directed to promotion in a two-level cache where apage is to be placed in the first level of cache (i.e., the first cache14) from the second level of cache (i.e., the second cache 18).Embodiments look at the recent history of the page being promoted. Ifthe page has been relatively hot, the cache manager 24 places the hotpage at the MRU end of the LRU list of the first level of cache. If thepage has been relatively cold, the cache manager 24 places the page incondition to be evicted quickly (i.e., at the LRU end of the MRU list ofthe first level of cache).

The described operations may be implemented as a method, apparatus orcomputer program product using standard programming and/or engineeringtechniques to produce software, firmware, hardware, or any combinationthereof. Accordingly, aspects of the embodiments may take the form of anentirely hardware embodiment, an entirely software embodiment (includingfirmware, resident software, micro-code, etc.) or an embodimentcombining software and hardware aspects that may all generally bereferred to herein as a “circuit,” “module” or “system.” Furthermore,aspects of the embodiments may take the form of a computer programproduct embodied in one or more computer readable medium(s) havingcomputer readable program code embodied thereon.

Any combination of one or more computer readable medium(s) may beutilized. The computer readable medium may be a computer readable signalmedium or a computer readable storage medium. A computer readablestorage medium may be, for example, but not limited to, an electronic,magnetic, optical, electromagnetic, infrared, or semiconductor system,apparatus, or device, or any suitable combination of the foregoing. Morespecific examples (a non-exhaustive list) of the computer readablestorage medium would include the following: an electrical connectionhaving one or more wires, a portable computer diskette, a hard disk, arandom access memory (RAM), a read-only memory (ROM), an erasableprogrammable read-only memory (EPROM or Flash memory), an optical fiber,a portable compact disc read-only memory (CD-ROM), an optical storagedevice, a magnetic storage device, or any suitable combination of theforegoing. In the context of this document, a computer readable storagemedium may be any tangible medium that can contain or store a programfor use by or in connection with an instruction execution system,apparatus, or device.

A computer readable signal medium may include a propagated data signalwith computer readable program code embodied therein, for example, inbaseband or as part of a carrier wave. Such a propagated signal may takeany of a variety of forms, including, but not limited to,electro-magnetic, optical, or any suitable combination thereof. Acomputer readable signal medium may be any computer readable medium thatis not a computer readable storage medium and that can communicate,propagate, or transport a program for use by or in connection with aninstruction execution system, apparatus, or device.

Program code embodied on a computer readable medium may be transmittedusing any appropriate medium, including but not limited to wireless,wireline, optical fiber cable, RF, etc., or any suitable combination ofthe foregoing.

Computer program code for carrying out operations for aspects of thepresent invention may be written in any combination of one or moreprogramming languages, including an object oriented programming languagesuch as Java, Smalltalk, C++ or the like and conventional proceduralprogramming languages, such as the “C” programming language or similarprogramming languages. The program code may execute entirely on theuser's computer, partly on the user's computer, as a stand-alonesoftware package, partly on the user's computer and partly on a remotecomputer or entirely on the remote computer or server. In the latterscenario, the remote computer may be connected to the user's computerthrough any type of network, including a local area network (LAN) or awide area network (WAN), or the connection may be made to an externalcomputer (for example, through the Internet using an Internet ServiceProvider).

Aspects of the present invention are described above with reference toflowchart illustrations and/or block diagrams of methods, apparatus(systems) and computer program products according to embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, can be implemented bycomputer program instructions. These computer program instructions maybe provided to a processor of a general purpose computer, specialpurpose computer, or other programmable data processing apparatus toproduce a machine, such that the instructions, which execute via theprocessor of the computer or other programmable data processingapparatus, create means for implementing the functions/acts specified inthe flowchart and/or block diagram block or blocks.

These computer program instructions may also be stored in a computerreadable medium that can direct a computer, other programmable dataprocessing apparatus, or other devices to function in a particularmanner, such that the instructions stored in the computer readablemedium produce an article of manufacture including instructions whichimplement the function/act specified in the flowchart and/or blockdiagram block or blocks.

The computer program instructions may also be loaded onto a computer,other programmable data processing apparatus, or other devices to causea series of operational steps to be performed on the computer, otherprogrammable apparatus or other devices to produce a computerimplemented process such that the instructions which execute on thecomputer or other programmable apparatus provide processes forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks.

The terms “an embodiment”, “embodiment”, “embodiments”, “theembodiment”, “the embodiments”, “one or more embodiments”, “someembodiments”, and “one embodiment” mean “one or more (but not all)embodiments of the present invention(s)” unless expressly specifiedotherwise.

The terms “including”, “comprising”, “having” and variations thereofmean “including but not limited to”, unless expressly specifiedotherwise.

The enumerated listing of items does not imply that any or all of theitems are mutually exclusive, unless expressly specified otherwise.

The terms “a”, “an” and “the” mean “one or more”, unless expresslyspecified otherwise.

Devices that are in communication with each other need not be incontinuous communication with each other, unless expressly specifiedotherwise. In addition, devices that are in communication with eachother may communicate directly or indirectly through one or moreintermediaries.

A description of an embodiment with several components in communicationwith each other does not imply that all such components are required. Onthe contrary a variety of optional components are described toillustrate the wide variety of possible embodiments of the presentinvention.

Further, although process steps, method steps, algorithms or the likemay be described in a sequential order, such processes, methods andalgorithms may be configured to work in alternate orders. In otherwords, any sequence or order of steps that may be described does notnecessarily indicate a requirement that the steps be performed in thatorder. The steps of processes described herein may be performed in anyorder practical. Further, some steps may be performed simultaneously.

When a single device or article is described herein, it will be readilyapparent that more than one device/article (whether or not theycooperate) may be used in place of a single device/article. Similarly,where more than one device or article is described herein (whether ornot they cooperate), it will be readily apparent that a singledevice/article may be used in place of the more than one device orarticle or a different number of devices/articles may be used instead ofthe shown number of devices or programs. The functionality and/or thefeatures of a device may be alternatively embodied by one or more otherdevices which are not explicitly described as having suchfunctionality/features. Thus, other embodiments of the present inventionneed not include the device itself.

The illustrated operations of FIGS. 7-13 and 15 show certain eventsoccurring in a certain order. In alternative embodiments, certainoperations may be performed in a different order, modified or removed.Moreover, steps may be added to the above described logic and stillconform to the described embodiments. Further, operations describedherein may occur sequentially or certain operations may be processed inparallel. Yet further, operations may be performed by a singleprocessing unit or by distributed processing units.

The foregoing description of various embodiments of the invention hasbeen presented for the purposes of illustration and description. It isnot intended to be exhaustive or to limit the invention to the preciseform disclosed. Many modifications and variations are possible in lightof the above teaching. It is intended that the scope of the invention belimited not by this detailed description, but rather by the claimsappended hereto. The above specification, examples and data provide acomplete description of the manufacture and use of the composition ofthe invention. Since many embodiments of the invention can be madewithout departing from the spirit and scope of the invention, theinvention resides in the claims herein after appended.

1. A computer program product for managing data in a first cache and asecond cache, the computer program product comprising a computerreadable storage medium having computer readable program code embodiedtherein that executes to perform operations, the operations comprising:maintaining a reference count in the second cache for a page when thepage is stored in the second cache; determining that the page is to bepromoted from the second cache to the first cache; in response todetermining that the reference count is greater than zero, adding thepage to a Least Recently Used (LRU) end of an LRU list in the firstcache; and in response to determining that the reference count is lessthan or equal to zero, adding the page to a Most Recently Used (LRU) endof the LRU list in the first cache.
 2. The computer program product ofclaim 1, wherein the first cache and the second cache are coupled tostorage.
 3. The computer program product of claim 2, wherein the firstcache is a faster access device than the second cache, and wherein thesecond cache is a faster access device than the storage.
 4. The computerprogram product of claim 2, wherein the first cache comprises a RandomAccess Memory (RAM), the second cache comprises a flash device, and thestorage comprises a sequential write device.
 5. The computer programproduct of claim 1, wherein the reference count comprises a firstreference count, and wherein the operations further comprise:maintaining a second reference count in the first cache for the pagewhen the page is stored in the first cache, wherein the second referencecount for the page in the first cache is incremented upon each referenceto the page in the first cache.
 6. The computer program product of claim1, wherein the operations further comprise: decrementing the referencecount for the page in the second cache upon each reference to the pagein the second cache.
 7. The computer program product of claim 1, whereinthe reference count comprises a first reference count, and wherein theoperations further comprise: in response to determining that the page isdemoted from the first cache to the second cache, determining whetherthe first reference count is less than zero; and in response todetermining that the first reference count is less than zero, settingthe first reference count equal to a constant (k) times a secondreference count.
 8. A system for managing data, comprising: a firstcache; a second cache; a processor; a computer readable storage mediumhaving code executed by the processor to perform operations, theoperations comprising: maintaining a reference count in the second cachefor a page when the page is stored in the second cache; determining thatthe page is to be promoted from the second cache to the first cache; inresponse to determining that the reference count is greater than zero,adding the page to a Least Recently Used (LRU) end of an LRU list in thefirst cache; and in response to determining that the reference count isless than or equal to zero, adding the page to a Most Recently Used(LRU) end of the LRU list in the first cache.
 9. The system of claim 8,wherein the first cache and the second cache are coupled to storage. 10.The system of claim 9, wherein the first cache is a faster access devicethan the second cache, and wherein the second cache is a faster accessdevice than the storage.
 11. The system of claim 9, wherein the firstcache comprises a Random Access Memory (RAM), the second cache comprisesa flash device, and the storage comprises a sequential write device. 12.The system of claim 8, wherein the reference count comprises a firstreference count, and wherein the operations further comprise:maintaining a second reference count in the first cache for the pagewhen the page is stored in the first cache, wherein the second referencecount for the page in the first cache is incremented upon each referenceto the page in the first cache.
 13. The system of claim 8, wherein theoperations further comprise: decrementing the reference count for thepage in the second cache upon each reference to the page in the secondcache.
 14. The system of claim 8, wherein the reference count comprisesa first reference count, and wherein the operations further comprise: inresponse to determining that the page is demoted from the first cache tothe second cache, determining whether the first reference count is lessthan zero; and in response to determining that the first reference countis less than zero, setting the first reference count equal to a constant(k) times a second reference count. 15-21. (canceled)